home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / quicktime / quicktime for java / imagecompositing / src / layerchanger.java < prev    next >
Encoding:
Java Source  |  2000-06-23  |  2.1 KB  |  68 lines

  1. /*
  2.  * QuickTime for Java SDK Sample Code
  3.  
  4.    Usage subject to restrictions in SDK License Agreement
  5.  * Copyright: © 1996-1999 Apple Computer, Inc.
  6.  
  7.  */
  8. import quicktime.app.display.*;
  9. import quicktime.app.actions.*;
  10. import java.awt.event.*;
  11. import quicktime.app.image.*;
  12. import quicktime.*;
  13.  
  14. public class LayerChanger extends MouseResponder {
  15.     /**
  16.      * Set some parameters that will create DragActions. 
  17.      * @param modifierKeyMask - if specified will determine which modifier keys must
  18.      * be depressed for the action to be invoked.
  19.      */
  20.     public LayerChanger (int modifierKeyMask) {
  21.         this (modifierKeyMask, MouseResponder.kModifiersExactMatch, MouseResponder.kClickEvents);
  22.     }
  23.  
  24.     /**
  25.      * Set some parameters that will create DragActions. 
  26.      * @param modifierKeyMask - if specified will determine which modifier keys must
  27.      * be depressed for the action to be invoked.
  28.      * @param modifierTestConditions the test conditions under which the modifier mask is tested
  29.      */
  30.     public LayerChanger (int modifierKeyMask, int modifierTestConditions, int eventInvoker) {
  31.         super (modifierKeyMask, modifierTestConditions, eventInvoker);
  32.     }    
  33. //____________________________ INSTANCE VARIABLES
  34.     private Layerable current;
  35.     private QTDisplaySpace group;
  36.     
  37. //____________________________ INSTANCE METHODS
  38. // This will throw a ClassCastException if the Space is incorrect
  39. // it is called by the MouseController constructor and thus if this cast
  40. // fails then the controller won't be constructed.
  41.     protected void setTargetSpace (Object space) {
  42.         group = (QTDisplaySpace)space;
  43.     }
  44.  
  45.     protected void setTarget (Object t) {
  46.         current = group.getLayerable(t);
  47.     }
  48.  
  49.     protected void removeTarget () {
  50.         current = null;
  51.     }
  52.     
  53.     public boolean isAppropriate (Object object) {
  54.         return true;
  55.     }
  56.     
  57.     public void mouseClicked (MouseEvent e) {
  58.         try {
  59.             int layer = group.getBackLayer();        
  60.             current.setLayer (layer+1);
  61.         } catch (QTException ex) {
  62.             throw new QTRuntimeException (ex);
  63.         } finally {
  64.             current = null;    //we've finished with this event might as well drop it
  65.         }
  66.     }
  67. }
  68.